import { createApp } from 'vue'
// 解决控制台警告 Passive Event Listeners
import 'default-passive-events'
import './style/normalize.css'
import '@/style/root.less' // 主题css
import './style/common.css' // 公共css
import 'element-plus/theme-chalk/dark/css-vars.css'
import 'element-plus/dist/index.css'
import '@/style/layout.less' // 布局css
import 'animate.css' // 动画效果css

import { createPinia } from 'pinia'
import piniaPersist from 'pinia-plugin-persist'
// 引入iconfont文件
import "@/assets/iconfont/graphicon/iconfont"
import "@/assets/iconfont/systemicon/iconfont"
import "@/assets/iconfont/weathericon/iconfont"
import SvgIcon from '@/components/SvgIcon/index.vue'
import WithWait from "@/components/WithWait/index.vue"
import { vPermission } from './utils/custom-directive'
const pinia = createPinia()
pinia.use(piniaPersist)


import Router from './router'
import App from './App.vue'
import { ElMessage } from 'element-plus'
const app = createApp(App)


// 注册全局svg组件
app.component("svg-icon", SvgIcon)
// 注册全局loading组件
app.component("WithWait", WithWait)
// 注册全局指令
app.directive("permission",{
    mounted(el:HTMLElement,binding) {
        vPermission(el,binding)
    }
})
// 捕获错误
app.config.errorHandler = (err, vm, info) => {
    console.log(err, 'err');
    console.log(vm, 'vm');
    console.log(info, 'info');
    ElMessage.error(info)
    return false
}

app.use(pinia).use(Router)
app.mount('#app')
